
<template>
  <div style="height:100%;overflow:hidden;">
      <el-tabs v-model="TabValue" @tab-click="ResultTabClick" style="height:100%;" type="border-card" ref="tabs" class="Tabundefined RMTab ResultGerm">
          <el-tab-pane label="报告项目" name="1" style="height:100%;">
              <div :style="Options.doubleresultcol>0?'width:50%;float:left;height:100%':'height:100%'">
                  <vxe-table :data.sync="tableDataResult" @current-change="currentResultChangeEvent" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" :mouse-config="{selected: true}" :select-config="selectConfig" @cell-dblclick="DblEvent" @edit-actived="ResultActive" @edit-closed="ResultClose" :cell-class-name="ColumnClassName" :height="h" highlight-current-row ref="xTableResult" resizable border show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" :show-xscroll="xscrollflag" :loading="loadingResult" size="mini" :width="w" config-record-key="ResultTable" :tableid="tableid" status-msg-group="none" class="ResultTable">
                      <vxe-table-column type="index" width="30px" v-if="Options['input_hideresultno']=='0'" align="center"></vxe-table-column>
                      <vxe-table-column :field="items.field" :title="items.title" :width="items.width" v-for="(items) in tableResultColumn" v-bind:key="items.field" :align="items.field=='result_str'&&Options.resultstralignmentright>0?'right':'left'" :edit-render="{name: 'input', autoselect: true}" header-align="center">
                          <template v-slot="{ row }" v-if="items.field=='alertflag'||items.field=='redo_flag'||items.field=='modify_flag'">
                              <div v-if="items.field=='alertflag'&&row.alertflag>0" v-bind:style="{background:Options.alertflagcolor?Options.alertflagcolor:'red',height:'18px'}"></div>
                              <div v-else-if="items.field=='modify_flag'&&row.modify_flag>0" v-bind:style="{background:Options.modifyflagcolor?Options.modifyflagcolor:'#FFFFFF',height:'18px'}"></div>
                              <div v-else-if="items.field=='redo_flag'&&row.redo_flag == '2'" v-bind:style="{background:'rgb(00, 255, 00)',height:'18px'}"></div>
                              <div v-else-if="items.field=='redo_flag'&&(row.redo_flag == '1' || row.redo_flag == 'M')" v-bind:style="{background:'yellow',height:'18px'}"></div>
                              <div v-else></div>
                          </template>
                          <template v-slot="{ row }" v-else-if="items.field == 'rpt_itemname'">
                              <div :style="ResultClassName(row)">
                                  <span>{{row.rpt_itemname}}</span>
                              </div>
                          </template>
                          <template v-slot="{ row }" v-else-if="items.field=='result_str'">
                              <div :style="ResultClass(row)">
                                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                                  <span v-else>{{row.result_str}}</span>
                              </div>
                          </template>
                          <template v-slot="{ row }" v-else-if="items.field == 'cp_lastresult'">
                              <div :style="ResultClass(row, 'last')">
                                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.cp_lastresult}}</span>
                                  <span v-else>{{row.cp_lastresult}}</span>
                              </div>
                          </template>
                          <template v-slot="{ row }" v-else-if="items.field=='result_txt'">
                              <pre style="padding: 1px;white-space: pre-wrap;">{{ row.result_txt }}</pre>
                              <!-- <el-input v-if="editflag" v-model="row.result_txt" type="textarea" autosize class="txtClass" @dblclick.native="tempRptItem=row,dialogResultTxtVisible = true,ResultTxt = row.result_txt"></el-input> -->
                          </template>
                          <template v-slot:edit="{ row,rowIndex }" v-if="items.field=='rpt_itemname'">
                              <el-input v-if="editflag && row.alertrelease != '1' && Options.generesultcaninput && Options.generesultcaninput == '1'" @keyup.space.native="dialogRptVisible=true,tempRptItem=row,$nextTick(() => {$refs.rptdialog.$refs.qcodeinput.focus();});" @keyup.enter.native="$refs.xTableResult.setActiveCell(row,'result_str')" @keyup.down.native="ResultMove(row,1,rowIndex,'rpt_itemname')" @keyup.up.native="ResultMove(row,0,rowIndex,'rpt_itemname')" @change="rptitemInput(row)" v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true" ref="rptitemname"></el-input>
                              <div style="height:18px" :style="ResultClassName(row)" v-else>
                                  <span>{{row.rpt_itemname}}</span>
                              </div>
                          </template>
                          <template v-slot:edit="{ row, rowIndex }" v-else-if="items.field=='result_str'">
                              <!-- <el-input v-if="editflag" v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px"></el-input> -->
                              <el-input v-model="row.result_str" style="width: 100%;18px" ref="rinput" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" @dblclick.native="ResultDblClick" v-if="editflag && row.alertrelease != '1' && Options.generesultcaninput && Options.generesultcaninput == '1'">
                                  <i :class="iconclass" slot="suffix" @click="handleIconClick" v-show="tableDataResultAll.length > 0 && Options.showrptitemvalbyfocus > 0"></i>
                              </el-input>
                              <div ref="selectDialog" v-if="editflag && row.alertrelease != '1' && Options.generesultcaninput && Options.generesultcaninput == '1'" class="reqitem-dialog" v-show="textvalueshow" style="width:240px">
                                  <div class="reqitem-select">
                                      <vxe-table :data.sync="tableDataResultAll" max-height="250px" stripe resizable header-align="center" show-header-overflow highlight-hover-row :keyboard-config="keyConfig" show-overflow size="mini" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" @cell-click="ResultTextClick($event, row)" status-msg-group="none" class="ResultTxtTable">
                                          <!-- <vxe-table-column v-for="item in allReqsheetTable" :key="item.id" :field="item.data" :title="item.label" :width="item.width" :align="item.align" show-overflow-tooltip></vxe-table-column> -->
                                          <vxe-table-column field="textvalue" title="文字结果" width="160px" align="left" header-align="center" show-overflow-tooltip>
                                              <template v-slot="{ row }">
                                                  <div :style="ResultClass(row)">
                                                      <span>{{row.textvalue}}</span>
                                                  </div>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="result_flag" title="结果标志" width="80px" align="center" show-overflow-tooltip>
                                              <template v-slot="{ row }">
                                                  <span>{{ ReusltflagName(row.result_flag) }}</span>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="redoflag" title="复查标志" width="60px" align="center" show-overflow-tooltip></vxe-table-column>
                                          <vxe-table-column field="inputcode" title="输入码" width="80px" align="center" show-overflow-tooltip></vxe-table-column>
                                          <vxe-table-column field="seq" title="序号" width="40px" align="center" show-overflow-tooltip></vxe-table-column>
                                          <vxe-table-column field="containtext" title="录入码" width="100px" align="center" show-overflow-tooltip></vxe-table-column>
                                          <!-- <vxe-table-column field="col_name" title="字段名称" width="80"></vxe-table-column> -->
                                      </vxe-table>
                                  </div>
                              </div>
                              <!-- <el-autocomplete v-if="editflag" :popper-append-to-body="false" v-model="row.result_str" :fetch-suggestions="querySearch" placeholder="" @select="selectchange($event,row)" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" popper-class="mini-select rselect" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')">-->
                              <!-- <i class="el-icon-caret-bottom el-input__icon" slot="suffix" @click="handleIconClick"></i> -->
                              <!--<template slot-scope="{ item }">
                                      <div class="name">{{ item.textvalue }}</div>
                                  </template>
                              </el-autocomplete> -->
                              <!-- <el-select v-if="editflag" v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px" allow-create filterable @blur="selectBlur($event, row)" @change="selectchange($event,row)">
                                  <el-option v-for="item in tableDataResultAll" :key="item.seq" :value="item.textvalue" :label="item.textvalue"></el-option>
                              </el-select> -->
                              <div style="height:18px" :style="ResultClass(row)" v-else>
                                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                                  <span v-else>{{row.result_str}}</span>
                              </div>
                          </template>
                          <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result1'">
                              <el-input v-if="editflag" v-model="row.result1" @keyup.enter.native="AddRow(row,rowIndex,'result1','result2')" @keyup.down.native="ResultMove(row,1,rowIndex,'result1')" @keyup.up.native="ResultMove(row,0,rowIndex,'result1')" style="width:100%;height:18px"></el-input>
                              <span v-else style="height:18px">{{row.result1}}</span>
                          </template>
                          <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result2'">
                              <el-input v-if="editflag" v-model="row.result2" @keyup.enter.native="AddRow(row,rowIndex,'result2','result3')" @keyup.down.native="ResultMove(row,1,rowIndex,'result2')" @keyup.up.native="ResultMove(row,0,rowIndex,'result2')" style="width:100%;height:18px"></el-input>
                              <span v-else style="height:18px">{{row.result2}}</span>
                          </template>
                          <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result3'">
                              <el-input v-if="editflag" v-model="row.result3" @keyup.enter.native="AddRow(row,rowIndex,'result3','result4')" @keyup.down.native="ResultMove(row,1,rowIndex,'result3')" @keyup.up.native="ResultMove(row,0,rowIndex,'result3')" style="width:100%;height:18px"></el-input>
                              <span v-else style="height:18px">{{row.result3}}</span>
                          </template>
                          <template v-slot:edit="{ row }" v-else-if="items.field=='result_txt'">
                              <el-input v-if="editflag" v-model="row.result_txt" type="textarea" autosize class="txtClass" @dblclick.native="tempRptItem=row,dialogResultTxtVisible = true,ResultTxt = row.result_txt"></el-input>
                              <pre v-else style="height:18px">{{row.result_txt}}</pre>
                          </template>
                          <template v-slot:edit="{ row }" v-else>
                              <span style="height:18px">{{row[items.field]}}</span>
                          </template>
                      </vxe-table-column>
                  </vxe-table>
              </div>
              <div style="width:49%;float:left;height:100%" v-if="Options.doubleresultcol>0">
                  <vxe-table :data.sync="tableDataResult" @current-change="currentResultChangeEvent" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true}" :mouse-config="{selected: true}" :select-config="selectConfig" @cell-dblclick="DblEvent" @edit-actived="ResultActive" @edit-closed="ResultClose" :cell-class-name="ColumnClassName" :height="h" highlight-current-row highlight-hover-row ref="xTableResult" resizable highlight-hover-column border show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" :loading="loadingResult" status-msg-group="none" size="mini" stripe :width="w" :tableid="tableid1">
                      <vxe-table-column type="index" width="30px" v-if="Options['input_hideresultno']=='0'"></vxe-table-column>
                      <vxe-table-column field="rpt_itemname" v-if="!editflag" title="检验项目" key="rpt_itemname" width="200px"> </vxe-table-column>
                      <vxe-table-column v-else field="rpt_itemname" title="检验项目" key="rpt_itemname" width="200px" :edit-render="{name: 'input', autoselect: true}">
                          <template v-slot:edit="{ row,rowIndex }">
                              <el-input @keyup.space.native="dialogRptVisible=true,tempRptItem=row,$nextTick(() => {$refs.rptdialog.$refs.qcodeinput.focus();});" @keyup.enter.native="$refs.xTableResult.setActiveCell(row,'result_str')" @keyup.down.native="ResultMove(row,1,rowIndex,'rpt_itemname')" @keyup.up.native="ResultMove(row,0,rowIndex,'rpt_itemname')" @change="rptitemInput(row)" v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true" ref="rptitemname"></el-input>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="result_str" v-if="!editflag" title="检验结果" key="result_str" width="100px"> </vxe-table-column>
                      <vxe-table-column field="result_str" v-else title="检验结果" key="result_str" width="100px" :edit-render="{name: 'input', autoselect: true}" :align="Options.resultstralignmentright>0?'right':'left'">
                          <template v-slot="{ row }">
                              <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                              <span v-else>{{row.result_str}}</span>
                          </template>
                          <template v-slot:edit="{ row,rowIndex }">
                              <el-input v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex)" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px"></el-input>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column :field="item.field" :title="item.title" :width="item.width" v-for="(item) in tableResultColumn" v-bind:key="item.field"></vxe-table-column>
                  </vxe-table>
              </div>
          </el-tab-pane>
          <el-tab-pane v-if="Options.generesultcaninput != '1'" label="标本检验" name="2" style="height:100%;">
              <rmLabResultGene ref="resultgene" @genechange="GeneChange" :editflag="editflag"></rmLabResultGene>
              <div style="width:660px;">
                  <div>结果</div>
                  <div>
                      <el-input type="textarea" :rows="3" v-model="Generesult" @change="txtinfoChange" disabled></el-input>
                  </div>
              </div>
          </el-tab-pane>
          <el-tab-pane :label="getlabname()" name="3" style="height:100%;">
              <div style="width:100%;">
                  <div>{{this.txtinfo1name}}</div>
                  <div>
                      <el-input type="textarea" :rows="13" v-model="txtinfo1" @dblclick.native="txtdblEvent('txtinfo1')"></el-input>
                  </div>
              </div>
              <div style="width:100%;">
                  <div>{{this.txtinfo2name}}</div>
                  <div>
                      <el-input type="textarea" :rows="13" v-model="txtinfo2" @dblclick.native="txtdblEvent('txtinfo2')" ></el-input>
                  </div>
              </div>
          </el-tab-pane>
          <el-tab-pane label="实验室意见" name="4" style="height:100%;">
              <div style="width:100%;">
                  <div>
                      <el-input type="textarea" :rows="13" v-model="lab_advice" @dblclick.native="txtdblEvent('lab_advice')"></el-input>
                  </div>
              </div>
          </el-tab-pane>
          <el-tab-pane v-if="Options.showreportview == '1'" label="报告预览" name="5" style="height:100%;">
              <div style="width:100%;height:100%;" id="reportviewid">
                  <div v-html="reportviewstr"></div>
              </div>
          </el-tab-pane>
      </el-tabs>

      <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目" :visible.sync="dialogRptVisible" @close="$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')">
          <rm-pop-rptitem prgno="LIS310" @cancel="dialogRptVisible=false,$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')" :isAllRpt="1" :rptunitid="rptunitid" :rptunitdisabled="true" @selitem="addrptitem" ref="rptdialog"></rm-pop-rptitem>
      </el-dialog> -->

      <!--多选弹窗--->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialogRptVisible" :destroy-on-close="true" title="报告项目" v-if="dialogRptVisible" @close="this.linkshow = true,$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')">
          <rm-chkboxSelect2 prgno="LIS310" @cancel="dialogRptVisible=false,linkshow = true,$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')" :isAllRpt="1" :rptunitid="rptunitid" :rptunitdisabled="true" @selitem="addrptitem" @selitems="SelectRptItems" ref="rptdialog"></rm-chkboxSelect2>
      </el-dialog>

      <!--报告项目结果选择开窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目常见结果选择" :visible.sync="dialogResultVisible" v-if="dialogResultVisible">
          <el-container style="border: 1px solid #eee;height:600px">
              <el-main style="overflow: hidden;padding:0 0">
                  <el-input @keyup.enter.native="ResultSearchkeydown" placeholder="快速检索" prefix-icon="el-icon-search" ref="qcodeinput" style="width:300px;" v-model="Resultqcode"></el-input>
                  <el-button @click="Resultok" icon="el-icon-circle-check" style="margin-left:10px;">确定</el-button>
                  <el-button @click="Resultcancel" icon="el-icon-circle-close">取消</el-button>
                  <div style="height: 564px">
                      <vxe-table :data="tableDataResultS" @cell-dblclick="ResultSelect" border height="564px" highlight-current-row highlight-hover-row resizable size="mini" status-msg-group="none" stripe style="margin-top:10px" ref="xTableResultAll">
                          <vxe-table-column field="textvalue" title="文字结果" width="200px"></vxe-table-column>
                          <vxe-table-column field="result_flag" title="结果标志" width="60px"></vxe-table-column>
                          <vxe-table-column field="redoflag" title="复查标志" width="60px"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="快速输入码" width="80px"></vxe-table-column>
                          <vxe-table-column field="seq" title="序号" width="40px"></vxe-table-column>
                          <vxe-table-column field="containtext" title="录入码" width="80px"></vxe-table-column>
                          <!-- <vxe-table-column :field="item.field" :key="item.field" :title="item.title" width="100px" v-for="item in tableColumnResultAll"></vxe-table-column> -->
                      </vxe-table>
                  </div>
              </el-main>
          </el-container>
      </el-dialog>

      <!--报告项目文字结果选择开窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目常见结果选择" :visible.sync="dialogResultTxtVisible" v-if="dialogResultTxtVisible">
          <div>
              <el-input type="textarea" :rows="6" v-model="ResultTxt"></el-input>
          </div>
          <div>
              <table style="width:100%;border-spacing:0px;margin-top:5px">
                  <tr>
                      <td>
                          快速查找
                          <el-input v-model="Resultqcode" @keyup.enter.native="ResultSearchkeydown" placeholder="请输入要查找的信息" style="width:calc(100% - 60px)"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td style="width:450px">
                          <vxe-table :data="tableDataResultS" :select-config="selectConfig" :keyboard-config="keyConfig" @cell-click="AdviceClick" @cell-dblclick="AdvicedblClick" height="300px" highlight-current-row highlight-hover-row resizable highlight-hover-column border show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" size="mini" status-msg-group="none" stripe width="400px">
                              <vxe-table-column field="textvalue" title="文字结果" width="200px"></vxe-table-column>
                              <vxe-table-column field="result_flag" title="结果标志" width="60px"></vxe-table-column>
                              <vxe-table-column field="redoflag" title="复查标志" width="60px"></vxe-table-column>
                              <vxe-table-column field="inputcode" title="快速输入码" width="80px"></vxe-table-column>
                              <vxe-table-column field="seq" title="序号" width="40px"></vxe-table-column>
                              <vxe-table-column field="containtext" title="录入码" width="80px"></vxe-table-column>
                              <!-- <vxe-table-column :field="item.field" :key="item.field" :title="item.title" width="100px" v-for="item in tableColumnResultAll"></vxe-table-column> -->
                          </vxe-table>
                      </td>
                      <td>
                          <div style="margin-left:15px">
                              <el-button style="display:block" @click="AdviceSubmit()">确 定</el-button>
                              <el-button style="display:block;margin-left:0px;margin-top:5px" @click="dialogResultTxtVisible = false">取 消</el-button>
                              <el-checkbox v-model="appendChangeRow" style="margin-top:20px;display:block">追加时自动换行</el-checkbox>
                              <div style="margin-top:20px">
                                  <span style="color:blue;">说明:<br>单击为追加<br>双击为替换</span>
                              </div>
                          </div>
                      </td>
                  </tr>
              </table>
          </div>
      </el-dialog>

      <!--删除撤销弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="撤销删除" :visible.sync="dialogDelVisible" v-if="dialogDelVisible" width="600px">
          <div>
              <vxe-table :data.sync="tableDelData" border fit height="400px" header-align="center" highlight-current-row highlight-hover-row ref="xTableDel" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" status-msg-group="none" stripe>
                  <vxe-table-column type="selection" align="center" width="40px"></vxe-table-column>
                  <vxe-table-column field="rpt_itemname" title="检验项目" width="200px"></vxe-table-column>
                  <vxe-table-column field="result_str" title="修改前取值" width="100px"></vxe-table-column>
                  <vxe-table-column field="opratedt" title="操作时间" width="120px"></vxe-table-column>
              </vxe-table>
          </div>
          <div style="text-align: right">
              <el-button @click="SubmitCancelDel()">确 定</el-button>
              <el-button @click="dialogDelVisible = false">取 消</el-button>
          </div>
      </el-dialog>

      <!--查看项目历史结果弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="检验项目历史结果" :visible.sync="dialogItemhistoryVisible" v-if="dialogItemhistoryVisible" width="760px">
          <div>
              <vxe-table :data.sync="tableItemHData" border fit height="400px" header-align="center" highlight-current-row highlight-hover-row ref="xTableItemH" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" status-msg-group="none" stripe>
                  <vxe-table-column field="sampledate" title="样本日期" width="120px" align="center"></vxe-table-column>
                  <vxe-table-column field="sampleno" title="样本号" width="60px" align="center"></vxe-table-column>
                  <vxe-table-column field="rpt_itemname" title="检验项目" width="120px" align="center"></vxe-table-column>
                  <vxe-table-column field="result_str" title="检验结果" width="60px" align="right" header-align="center"></vxe-table-column>
                  <vxe-table-column field="specimen_name" title="标本类型" width="60px" align="center"></vxe-table-column>
                  <vxe-table-column field="rechk_user" title="审核者" width="60px" align="center"></vxe-table-column>
                  <vxe-table-column field="report_user" title="检验者" width="60px" align="center"></vxe-table-column>
                  <vxe-table-column field="pat_no" title="病人号" width="100px"></vxe-table-column>
                  <vxe-table-column field="pat_typename" title="病人类型" width="60px" align="center"></vxe-table-column>
                  <vxe-table-column field="result_flag" title="标志" width="40px" align="center"></vxe-table-column>
              </vxe-table>
          </div>
          <div style="text-align: right;padding-top: 5px">
              <el-button @click="dialogItemhistoryVisible = false">确 定</el-button>
              <!-- <el-button @click="dialogItemhistoryVisible = false">取 消</el-button> -->
          </div>
      </el-dialog>

      <!--关联报告项目开窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="关联报告项目查看" :visible.sync="dialogLinkRptVisible" v-if="dialogLinkRptVisible" width="1000px">
          <div>
              <table>
                  <tr>
                      <td>
                          <div :style="{ width: LinkChartShow?'485px':'985px' }">
                              <vxe-table :data.sync="tableDataLink" @cell-click="LinkClick" height="400px" show-overflow show-header-overflow resizable stripe header-align="center" border size="mini" :sort-config="{trigger: 'cell'}" :tree-config="{children: 'children', expandAll: false, trigger: 'row'}" :span-method="colspanMethod" :row-class-name="rowClassName" status-msg-group="none" :select-config="{labelField: 'link_rptitemcode'}">
                                  <vxe-table-column field="rpt_itemname" title="检验项目" width="120px" align="center" tree-node></vxe-table-column>
                                  <vxe-table-column field="result_str" title="检验结果" width="60px" align="right" head-align="center">
                                      <template v-slot="{ row }">
                                          <div :style="ResultClass(row)">
                                              <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                                              <span v-else>{{row.result_str}}</span>
                                          </div>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="result_ref" title="参考值" width="60px"></vxe-table-column>
                                  <vxe-table-column field="sampledate" title="样本日期" width="80px" align="center"></vxe-table-column>
                                  <vxe-table-column field="sampleno" title="样本号" width="60px" align="center"></vxe-table-column>
                                  <vxe-table-column field="rptunitname" title="报告单元" width="100px"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </td>
                      <td v-if="LinkChartShow">
                          <div style="width:500px">
                              <div id="dialogLinkChart" style="width: 100%;height:400px;vertical-align:center;"></div>
                          </div>
                      </td>
                  </tr>
              </table>

          </div>
          <div style="text-align: right;padding-top: 5px">
              <el-button @click="dialogLinkRptVisible = false">确 定</el-button>
              <!-- <el-button @click="dialogItemhistoryVisible = false">取 消</el-button> -->
          </div>
      </el-dialog>
      <!--检验意见悬浮窗--->
      <rm-floatwindow v-rm-drag-window :visible="dialogAdvicefloatwindowVisible" :isGene="true" :winStyle="floatwindowstyle3" :title="floatadvicetitle" @close="FloatClose">
          <div>
              <el-input type="textarea" :rows="6" v-model="txtadvice" @input="adviceinput"></el-input>
          </div>
          <div style="height: calc(100% - 130px)">
              <table style="width: 100%; border-spacing: 0px; margin-top: 5px; height: 100%">
                  <tr>
                      <td>
                          快速查找
                          <el-input v-model="advicesearchtxtFloat" @input="AdviceSearchFloat" placeholder="请输入要查找的信息" style="width: calc(100% - 60px)"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td style="height: 100%">
                          <vxe-table :data="tableDataAdvice" :loading="loadingAdvice" @cell-click="AdviceFloatClick" @cell-dblclick="AdviceFloatdblClick" height="100%" highlight-current-row highlight-hover-row resizable highlight-hover-column border show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" size="mini" stripe width="auto">
                              <vxe-table-column field="txttitle" title="标题" width="100px"></vxe-table-column>
                              <vxe-table-column field="txtinfo" title="文字描述" width="160px"></vxe-table-column>
                              <vxe-table-column field="seq" title="序号" width="80px"></vxe-table-column>
                              <vxe-table-column field="inputcode" title="输入码" width="80px"></vxe-table-column>
                          </vxe-table>
                      </td>
                      <td width="200">
                          <div style="margin-left: 15px; width: 200px; height: calc(100% - 30px)">
                              <el-checkbox v-model="appendChangeRowFloat" style="margin-top: 20px; display: block">追加时自动换行</el-checkbox>
                              <div style="margin-top: 20px">
                                  <span style="color: blue">说明:<br />单击为追加<br />双击为替换</span>
                              </div>
                          </div>
                      </td>
                  </tr>
              </table>
          </div>
      </rm-floatwindow>
  </div>
</template>
<script>
import { Promise } from "q";
import XE from "xe-utils";
import echarts from "echarts";
import rmLabResultGene from "./rm_Lab_Report_Sub/GeneGroup.vue";
export default {
  props: ["PatientInfo", "rptunitid", "pOptions", "h", "w", "checkmode"],
  name: "LIS310",
  data() {
      return {
          DelIndex: -1,
          TabValue: "1",
          reportviewstr: "",
          myrptunitid: this.rptunitid,
          tableDataResult: [],
          noupdateflag: true,
          tableDataResultOld: [],
          tableResultColumn: [],
          loadingResult: false,
          InputMsg: [],

          dialogRptVisible: false,

          selectConfig: { tigger: "row" },
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true
          },
          tempRptItem: {},
          xscrollflag: true,
          oldval: "", //激活时的旧result值
          //报告结果选择开窗
          dialogResultVisible: false,
          dialogResultItem: "", //报告结果项目
          Resultqcode: "",
          tableDataResultAll: [],
          tableDataResultS: [],
          tableColumnResultAll: [],
          editflag: true,
          Options: this.pOptions,
          Checkmode: this.checkmode,
          Refreshflag: false,
          ddlData: [],
          Generesult: "", //基因结果
          //撤销删除弹窗
          dialogDelVisible: false,
          tableDelData: [],
          //报告项目文本结果选择
          dialogResultTxtVisible: false,
          ResultTxt: "",
          appendChangeRow: false,
          //下拉框展示
          textvalueshow: false,
          iconclass: "el-icon-arrow-down",
          tableid: "",
          tableid1: "",
          //查看项目历史结果弹窗
          dialogItemhistoryVisible: false,
          tableItemHData: [],
          //关联项目查看弹窗
          dialogLinkRptVisible: false,
          linkshow: false,
          tableDataLink: [],
          LinkChartShow: false,
          panename:"文字描述1/文字描述2",
          txtinfo1:"",
          txtinfo2:"",
          txtinfo1name:"文字描述1",
          txtinfo2name:"文字描述2",

          dialogAdvicefloatwindowVisible:false,
          floatwindowstyle3: "top:100px;left:calc(15% + 40px );width:650px;height:400px", //文字描述浮动窗口回传样式
          floatadvicetitle:"文字描述1",
          txtadvice: "", //检验意见悬浮窗文字
          appendChangeRow: false, //报告文字描述结果行追加标志
          loadingAdvice: false, //报告文字描述结果加载标志
          tableDataAdvice: [], //报告文字描述结果显示数据
          tableDataAdviceAll: [], //报告文字描述结果全部数据
          appendChangeRowFloat: false, //检验意见浮动窗口追加行标志
          advicesearchtxtFloat: "", //检验意见浮动窗口关键词查询
          txtfield:"1",
          lab_advice:"",
      };
  },
  components: { rmLabResultGene },
  created() {
      this.InitPageData();
      this.getlabname();
  },
  mounted() {
      // 监听body上的点击
      document.querySelector("body").addEventListener("click", this.closeMenu);
      //this.TabValue = "2";
  },
  beforeDestroy() {
      // 移除监听
      document.querySelector("body").removeEventListener("click", this.closeMenu);
  },
  updated() {},
  methods: {
      InitPageData() {},

      //文字描述弹窗
      txtdblEvent(txttype){
          if (localStorage.getItem("floatwindowstyle314")) this.floatwindowstyle3 = localStorage.getItem("floatwindowstyle314");
              this.dialogAdvicefloatwindowVisible = true;
          if(txttype=='txtinfo1') {
              this.txtfield='1';
              this.floatadvicetitle='文字描述1';
              this.txtadvice=this.txtinfo1;
          }else if (txttype=='txtinfo2') {
              this.txtfield='2';
              this.floatadvicetitle='文字描述2';
              this.txtadvice=this.txtinfo2;
          }else if (txttype=='lab_advice'){
              this.txtfield='0';
              this.floatadvicetitle='实验意见';
              this.txtadvice=this.lab_advice;
          }

          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "getrptunittxtinfo",
                      rptunitid: this.rptunitid,
                      infotype: this.txtfield,
                  },
              })
              .then((res) => {
                  if (!res.hasOwnProperty("errcode")) {
                      this.tableDataAdviceAll = XE.clone(res, true);
                      this.tableDataAdvice = res;
                  }
              });

      },
      adviceinput(val){
          if(this.txtfield=='1') this.txtinfo1=val;
          else if(this.txtfield=='2') this.txtinfo2=val;
          else if(this.txtfield=='0') this.lab_advice=val;
      },
      FloatClose(style){
          this.dialogAdvicefloatwindowVisible = false;
          this.floatwindowstyle3 = style.cssText;
          localStorage.setItem("floatwindowstyle314", this.floatwindowstyle3);
      },
      AdviceSearchFloat(value) {
          if (value) {
              this.tableDataAdvice = this.tableDataAdviceAll.filter((item) => item.txttitle.toUpperCase().indexOf(value.toUpperCase()) > -1 || item.txtinfo.toUpperCase().indexOf(value.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(value.toUpperCase()) > -1);
          } else {
              this.tableDataAdvice = XE.clone(this.tableDataAdviceAll, true);
          }
      },
      AdviceFloatClick({ row }) {
          if (this.txtadvice) {
              if (this.txtadvice.indexOf(row.txtinfo) == -1) {
                  if (this.appendChangeRowFloat) {
                      this.txtadvice += "\n" + row.txtinfo;
                      if(this.txtfield=='1') this.txtinfo1 +="\n" + row.txtinfo;
                      else if(this.txtfield=='2') this.txtinfo2 +="\n" + row.txtinfo;
                      else if(this.txtfield=='0') this.lab_advice +="\n" + row.txtinfo;
                  } else {
                      if (this.txtadvice) {
                          this.txtadvice += "," + row.txtinfo;
                          if(this.txtfield=='1') this.txtinfo1 +="," + row.txtinfo;
                          else if(this.txtfield=='2') this.txtinfo2 +="," + row.txtinfo;
                          else if(this.txtfield=='0') this.lab_advice +="," + row.txtinfo;
                      } else {
                          this.txtadvice += row.txtinfo;
                          if(this.txtfield=='1') this.txtinfo1 += row.txtinfo;
                          else if(this.txtfield=='2') this.txtinfo2 += row.txtinfo;
                          else if(this.txtfield=='0') this.lab_advice += row.txtinfo;
                      }
                  }
              }
          } else {
              this.txtadvice = row.txtinfo;
              if(this.txtfield=='1') this.txtinfo1 = row.txtinfo;
              else if (this.txtfield=='2') this.txtinfo2 = row.txtinfo;
              else if (this.txtfield=='0') this.lab_advice = row.txtinfo;
          }
      },
      AdviceFloatdblClick({ row }) {
          this.txtadvice = row.txtinfo;
          if(this.txtfield=='1') this.txtinfo1 = row.txtinfo;
          else if (this.txtfield=='2') this.txtinfo2 = row.txtinfo;
          else if (this.txtfield=='0') this.lab_advice = row.txtinfo;
      },
      //上方按钮功能
      //新增
      ResultAdd() {
          return new Promise((s, f) => {
              var row = { rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, result_str: "" };
              this.$refs.xTableResult.insertAt(row, -1).then(() => {
                  var nowrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
                  this.$refs.xTableResult.setCurrentRow(nowrow).then(() => {
                      //this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname").then(() => {
                          s();
                      });
                  });
              });
          });

          //this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
      },
      ResultAddAsync() {
          if (!this.editflag) {
              return;
          }
          this.ResultAdd().then(() => {
              this.$emit("change");
              this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
          });
      },
      //删除
      ResultDel() {
          let row = this.$refs.xTableResult.getCurrentRow();
          if (!this.editflag) {
              return;
          }
          if (row.alertrelease == "1") {
              this.$alert("当前结果已单独上报危急值,请先召回危急值再删除", "提示");
              return;
          }
          this.$table.DelRecordSelect(this.$refs.xTableResult, this.DelIndex, this);
          var nowrow = this.$refs.xTableResult.getCurrentRow();
          this.linkshow = true;
          this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
      },
      ResultDelAsync() {
          new Promise(resolve => {
              this.ResultDel();
              resolve();
          }).then(() => {
              this.$emit("change");
              this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
          });
      },
      ClearNoDoItems() {
          return new Promise((s, f) => {
              if (this.editflag) {
                  var delrow = [];
                  this.$refs.xTableResult.tableFullData.forEach(t => {
                      if (!t.result_str || t.result_str == "" || t.result_str == "未做") {
                          delrow.push(t);
                      }
                  });
                  delrow.forEach(element => {
                      this.$refs.xTableResult.remove(element);
                  });
                  // var tmplis = this.tableDataResult.filter(t => t.result_str && t.result_str != "" && t.result_str != "未做");
                  // this.tableDataResult = tmplis;
                  s();
              } else {
                  f();
              }
          });
      },
      //表格功能
      currentResultChangeEvent({ row }) {
          //console.log(row);
      },
      ColumnClassName({ seq, row, rowIndex, $rowIndex, column }) {
          if (column.property != "rpt_itemname" && column.property != "result_str" && column.property != "alertflag" && column.property != "redo_flag" && column.property != "modify_flag" && column.property != "result1" && column.property != "result2" && column.property != "result3" && column.property != "result4" && column.property != "result_txt") {
              var style = "";
              if (row.keyitem == "1") style += "fontbold";
              style += " disabled-cell paddingcolumn";
              return style;
          }
          if (column.property == "alertflag" || column.property == "redo_flag" || column.property == "modify_flag") {
              return "disabled-cell";
          }
          if (column.property == "rpt_itemname") {
              var style = "";
              if (row.keyitem == "1") style += "fontbold";
              if (row.lab_rptunit_item_unprintflag == "1") {
                  style += " unprint";
                  return style;
              }
              if (row.alertflag) {
                  if (row.alertflag.trim() - 0) {
                      style += " danger paddingcolumn";
                      return style;
                  } else {
                      style += " paddingcolumn";
                      return style;
                  }
              } else {
                  style += " paddingcolumn";
                  return style;
              }
          }
          if (row.keyitem == "1") {
              return "fontbold";
          }
      },
      ResultClass(row, type) {
          var stylestr = "padding:0 3px;";
          if (this.Options.resultcolor_mode == "1") stylestr += "color:";
          else stylestr += "background-color:";
          var flag = row.result_flag;
          if (type && type == "last") flag = row.cp_lastresultflag;
          switch (flag) {
              case "M":
                  stylestr += this.Options.resultcolor_m;
                  break;
              case "H":
                  stylestr += this.Options.resultcolor_h;
                  break;
              case "L":
                  stylestr += this.Options.resultcolor_l;
                  break;
              case "P":
                  stylestr += this.Options.resultcolor_p;
                  break;
              case "W":
                  stylestr += this.Options.resultcolor_w;
                  break;
              case "E":
                  stylestr += this.Options.resultcolor_e;
                  break;
              case "Q":
                  stylestr += this.Options.resultcolor_r;
                  break;
              default:
                  stylestr += this.Options.resultcolor_m;
                  break;
          }
          if (row.result_str == "未做") {
              stylestr += ";color: #0095D9";
          }
          return stylestr;
      },
      ResultClassName(row) {
          var stylestr = "padding:0 3px;";
          if (row.alertflag > 0) stylestr += "background-color:" + (this.Options.alertflagcolor ? this.Options.alertflagcolor : "red") + ";";
          if (row.linkitemfalg == "1") stylestr += "text-decoration:underline;";
          return stylestr;
      },
      ReusltflagName(flag) {
          switch (flag) {
              case "M":
                  return "正常";
              case "H":
                  return "偏高";
              case "L":
                  return "偏低";
              case "P":
                  return "阳性";
              case "W":
                  return "弱阳性";
              case "E":
                  return "错误";
              case "Q":
                  return "非敏感";
              default:
                  return "";
          }
      },
      ResultActive({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
          //return;
          if (!this.editflag) return;
          if (column.property == "result_str") {
              this.iconclass = "el-icon-arrow-down";
              this.textvalueshow = false;
              this.QueryResultAll(row.rpt_itemcode, 0);
              //this.oldval = row.result_str;
          }
          if (column.property == "result1") {
              this.QueryResultAll(row.rpt_itemcode, 1);
              //this.oldval = row.result_str;
          }
          if (column.property == "result2") {
              this.QueryResultAll(row.rpt_itemcode, 2);
              //this.oldval = row.result_str;
          }
          if (column.property == "result3") {
              this.QueryResultAll(row.rpt_itemcode, 3);
              //this.oldval = row.result_str;
          }
          if (column.property == "result_txt") {
              this.QueryResultAll(row.rpt_itemcode, 0);
              //this.oldval = row.result_str;
          }
          if (column.property == "rpt_itemname") {
              if (row.linkitemfalg == "1") {
                  console.log("link", this.linkshow);
                  if (!this.linkshow) {
                      this.QueryLinkItem(row.rpt_itemcode);
                      this.LinkChartShow = false;
                      this.dialogLinkRptVisible = true;
                  }
                  this.linkshow = false;
              }
              // this.$nextTick(() => {
              //     if (this.$refs.rptitemname) {
              //         this.$refs.rptitemname.focus();
              //     }
              // });
              //this.oldval = row.rpt_itemcode;
          }
          this.oldval = row[column.property];
      },
      // ResultClick({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
      //     if (column.property == "rpt_itemname") {
      //         if (this.Options.linkdt.find(item => item.rpt_itemcode == row.rpt_itemcode)) {
      //             this.dialogLinkRptVisible = true;
      //         }
      //     }
      // },
      ResultClose({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
          if (!this.editflag) return;
          if (column.property == "result_str") {
              if (row.result_str) {
                  var selectrow = this.tableDataResultAll.filter(item => item.inputcode == row.result_str);
                  if (selectrow.length > 0) {
                      row.result_str = selectrow[0].textvalue;
                  }
              }
              //if (this.oldval != row.result_str) this.$emit("change");
              this.StrChange(row);
              this.textvalueshow = false;
              //this.CalcRef(row);
          }
          if (column.property == "rpt_itemname") {
              this.linkshow = false;
              //if (this.oldval != row.rpt_itemcode) this.$emit("change");
          }
          if (this.oldval != row[column.property]) this.$emit("change");
      },
      async rptitemInput(row) {
          this.ddlData = await this.$ddldata.getrptunititem(this.myrptunitid);
          var select = this.ddlData.filter(item => item.rpt_itemcode.toUpperCase() == row.rpt_itemname.toUpperCase() || item.itemcode_en.toUpperCase() == row.rpt_itemname.toUpperCase() || item.rpt_itemname.toUpperCase() == row.rpt_itemname.toUpperCase() || item.inputcode.toUpperCase() == row.rpt_itemname.toUpperCase());
          if (select && select.length > 0) {
              this.tempRptItem = row;
              this.addrptitem(select[0].rpt_itemcode, select[0].rpt_itemname, select[0]);
          } else {
              row.rpt_itemname = "";
          }
      },
      AddRow(row, rowIndex, coltype1, coltype2) {
          var lastrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
          var hascol = false;
          var selectdata = [];
          if (this.tableResultColumn) {
              selectdata = this.tableResultColumn.find(item => item.field == coltype2);
          }
          if (selectdata) {
              hascol = true;
          }
          if (lastrow._XID == row._XID && !hascol) {
              var newrow = { rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid };
              this.$refs.xTableResult.insertAt(newrow, -1).then(() => {
                  var nowrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
                  this.$nextTick(() => {
                      this.$refs.xTableResult.setCurrentRow(nowrow);
                      this.$refs.xTableResult.clearSelected();
                      this.$refs.xTableResult.clearActived();
                      //this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
                  });
              });
          } else {
              var thisrow = this.$refs.xTableResult.tableFullData[rowIndex + 1];
              if (hascol) thisrow = this.$refs.xTableResult.getCurrentRow();
              this.$nextTick(() => {
                  this.$refs.xTableResult.setCurrentRow(thisrow);
                  this.$refs.xTableResult.clearSelected();
                  this.$refs.xTableResult.clearActived();
                  this.$nextTick(() => {
                      if (thisrow && hascol) {
                          this.$refs.xTableResult.setActiveCell(thisrow, coltype2);
                      } else {
                          if (thisrow.hasOwnProperty("rpt_itemcode") && thisrow.rpt_itemcode) {
                              this.$refs.xTableResult.setActiveCell(thisrow, "result_str");
                          } else {
                              //this.linkshow = true;
                              this.$refs.xTableResult.setActiveCell(thisrow, "rpt_itemname");
                          }
                      }
                  });
              });
          }
      },
      listsearch() {
          var val = this.listsearchkey;
          this.tableDataListS = this.tableDataList.filter(item => {
              return item.pat_name.toUpperCase().indexOf(val.toUpperCase()) > -1 || item.barcode.toUpperCase().indexOf(val.toUpperCase()) > -1;
          });
      },
      ResultMove(row, type, index, coltype) {
          if (type == 1) {
              if (index < this.$refs.xTableResult.tableFullData.length - 1) {
                  var row = this.$refs.xTableResult.tableFullData[index + 1];
                  this.$refs.xTableResult.setCurrentRow(row);
                  if (coltype == "rpt_itemname") {
                      this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(row, "rpt_itemname");
                  } else {
                      this.$refs.xTableResult.setActiveCell(row, coltype);
                  }
              }
          } else {
              if (index != 0) {
                  var row = this.$refs.xTableResult.tableFullData[index - 1];
                  this.$refs.xTableResult.setCurrentRow(row);
                  if (coltype == "rpt_itemname") {
                      this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(row, "rpt_itemname");
                  } else {
                      this.$refs.xTableResult.setActiveCell(row, coltype);
                  }
              }
          }
      },
      ListDblClick({ row, rowIndex, $rowIndex, column }) {
          if (column.property == "pat_name" && this.Options.doublefilterpatname > 0) {
              this.tableDataListS = this.tableDataList.filter(item => item.pat_name == row.pat_name);
          }
          if (column.property == "req_reason" && this.Options.doublefilterrs > 0) {
              this.tableDataListS = this.tableDataList.filter(item => item.req_reason == row.req_reason);
          }
          if (column.property == "specimen_code" && this.Options.doublefilterrs > 0) {
              this.tableDataListS = this.tableDataList.filter(item => item.specimen_code == row.specimen_code);
          }
      },

      DblEvent({ row, rowIndex, $rowIndex, column }) {
          if (!this.editflag || row.alertrelease == "1") return;
          switch (column.property) {
              case "rpt_itemname":
                  this.dialogRptVisible = true;
                  this.$nextTick(() => {
                      this.$refs.rptdialog.$refs.qcodeinput.focus();
                  });
                  this.tempRptItem = row;
                  break;
              case "result1":
                  //this.QueryResultAll(row.rpt_itemcode, 0);
                  this.dialogResultVisible = true;
                  this.dialogResultItem = "result1";
                  if (this.tableDataResultS.length > 0)
                      this.$nextTick(() => {
                          this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
                      });
                  break;
              case "result2":
                  //this.QueryResultAll(row.rpt_itemcode, 0);
                  this.dialogResultVisible = true;
                  this.dialogResultItem = "result2";
                  if (this.tableDataResultS.length > 0)
                      this.$nextTick(() => {
                          this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
                      });
                  break;
              case "result3":
                  //this.QueryResultAll(row.rpt_itemcode, 0);
                  this.dialogResultVisible = true;
                  this.dialogResultItem = "result3";
                  if (this.tableDataResultS.length > 0)
                      this.$nextTick(() => {
                          this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
                      });
                  break;
              case "cp_lastresult":
                  this.QueryItemHistory(row.rpt_itemcode);
                  break;
          }
      },
      //双击弹窗添加项目
      addrptitem(c, n, row) {
          var rename = "";
          switch (this.Options.itemshowmode) {
              case "1":
                  rename = "[" + row.itemcode_en + "]";
                  break;
              case "2":
                  rename = n + " [" + row.itemcode_en + "]";
                  break;
              case "3":
                  rename = n;
                  break;
              case "4":
                  rename = "[" + row.itemcode_en + "] " + n;
                  break;
              case "5":
                  rename = c;
                  break;
              default:
                  rename = "[" + row.itemcode_en + "] " + n;
                  break;
          }
          var currentrow = this.$refs.xTableResult.getCurrentRow();
          var rowindex = this.$refs.xTableResult.getRowIndex(currentrow);
          var hasrow = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == c);
          if (hasrow.length > 0 && currentrow.rpt_itemcode != c) {
              this.$confirm("不能选择重复的项目", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  focusCancelButton: false,
                  type: "warning"
              })
                  .then(() => {
                      this.tempRptItem.rpt_itemname = "";
                      this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname").then(() => {
                          if (this.$refs.rptitemname) {
                              this.$refs.rptitemname.focus();
                          }
                      });
                  })
                  .catch(() => {
                      this.tempRptItem.rpt_itemname = "";
                      this.linkshow = true;
                      this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname").then(() => {
                          if (this.$refs.rptitemname) {
                              this.$refs.rptitemname.focus();
                          }
                      });
                  });
          } else {
              // for (var pKey in this.tempRptItem) {
              //     if (pKey == "rpt_itemname") {
              //         this.tempRptItem.rpt_itemname = rename;
              //     } else if (row.hasOwnProperty(pKey)) {
              //         if (this.tempRptItem[pKey] != row[pKey]) {
              //             this.tempRptItem[pKey] = row[pKey];
              //         }
              //     }
              // }
              this.tempRptItem.rpt_itemcode = c;
              this.tempRptItem.rpt_itemname = rename;
              this.tempRptItem.result_unit = row.unit;
              this.tempRptItem.result_ref = row.ref_text;
              this.tempRptItem.germflag = row.germflagid;
              this.tempRptItem.testmethod = row.testmethod;
              this.tempRptItem.itemcode_en = row.itemcode_en;
              if (row.defaultval) {
                  this.tempRptItem.result_str = row.defaultval;
              }
              this.tempRptItem.keyitem = row.keyitem;
              if (this.dialogRptVisible) {
                  this.$nextTick(() => {
                      this.$refs.xTableResult.setActiveCell(currentrow, "result_str");
                  });
              }
          }
          this.dialogRptVisible = false;
      },
      SelectRptItems(rows) {
          var indexdata = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == "" || item.rpt_itemcode == null);
          var indexs = [];
          for (let j = 0; j < indexdata.length; j++) {
              indexs.push(this.$refs.xTableResult.tableFullData.indexOf(indexdata[j]));
          }
          for (let i = 0; i < rows.length; i++) {
              let row = rows[i];
              var hasrow = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == row.rpt_itemcode);
              if (hasrow.length > 0) {
                  continue;
              }
              var rename = "";
              switch (this.Options.itemshowmode) {
                  case "1":
                      rename = "[" + row.itemcode_en + "]";
                      break;
                  case "2":
                      rename = row.rpt_itemname + " [" + row.itemcode_en + "]";
                      break;
                  case "3":
                      rename = row.rpt_itemname;
                      break;
                  case "4":
                      rename = "[" + row.itemcode_en + "] " + row.rpt_itemname;
                      break;
                  case "5":
                      rename = row.rpt_itemcode;
                      break;
                  default:
                      rename = "[" + row.itemcode_en + "] " + row.rpt_itemname;
                      break;
              }
              var insertrow = { rpt_itemname: rename, rpt_itemcode: row.rpt_itemcode, result_unit: row.unit, result_ref: row.ref_text, germflag: row.germflagid, testmethod: row.testmethod, itemcode_en: row.itemcode_en, rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, result_str: "", keyitem: row.keyitem };
              if (i < indexs.length) {
                  for (var item in insertrow) {
                      this.$refs.xTableResult.tableFullData[indexs[i]][item] = insertrow[item];
                  }
              } else {
                  this.$refs.xTableResult.insertAt(insertrow, -1);
              }
              // if(i == 0)
              // {
              //     this.tempRptItem.rpt_itemcode = row.rpt_itemcode;
              //     this.tempRptItem.rpt_itemname = rename;
              //     this.tempRptItem.result_unit = row.unit;
              //     this.tempRptItem.result_ref = row.ref_text;
              //     this.tempRptItem.germflag = row.germflagid;
              //     this.tempRptItem.testmethod = row.testmethod;
              //     this.tempRptItem.itemcode_en = row.itemcode_en;
              // }
              // else
              // {

              // }
          }
          var currentrow = this.$refs.xTableResult.getCurrentRow();
          if (this.dialogRptVisible) {
              this.$nextTick(() => {
                  this.$refs.xTableResult.setActiveCell(currentrow, "result_str");
              });
          }
          this.dialogRptVisible = false;
      },
      CenterDblClick(e) {
          this.ResultAddAsync();
      },
      RefreshOptions(p, checkmode) {
          this.Options = p;
          //this.tableResultColumn = this.Options.rCols;
          this.RefreshColumns(this.tableResultColumn, checkmode ? checkmode : false);
      },

      RefreshColumns(column, checkmode) {
          this.tableResultColumn = XE.clone(this.Options.rCols, true);
          column = this.tableResultColumn;
          if (checkmode) {
              var lastindex = column.findIndex(item => item.field == "cp_lastresult");
              for (let i = 5; i > 0; i--) {
                  //if (i < 5) lastindex = column.findIndex(item => item.field == "cp_lastresult" + i);
                  var row = { field: "cp_lastresult" + (i - 1), title: this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i, width: "80px" };
                  if (i == 1) {
                      lastindex = column.findIndex(item => item.field == "cp_lastresult");
                      // row = { field: "cp_lastresult", title: this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i, width: "80px" };
                      column[i].title = this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i;
                  } else {
                      column.splice(lastindex, 0, row);
                  }
              }
          }
          let colnamestr = "_undefined"; //兼容以前保存的本地设置，前面的index列，在vxe-table里面之前取的_undefined
          this.tableResultColumn.forEach(function(item) {
              colnamestr += "_" + item.field;
          });
          colnamestr = this.$tool.MD5(colnamestr);
          let _this = this;
          this.$nextTick(() => {
              _this.tableid = colnamestr; // this.myrptunitid.toString();
              if(this.Options.doubleresultcol >0){
                  _this.tableid1 = colnamestr; // this.myrptunitid.toString();
              }
          });
          console.log("cols", this.tableResultColumn);
      },
      ClearTableDate() {
          return new Promise((s, f) => {
              this.tableDataResult = [];
              this.editflag = true;
              s();
          });
      },
      QueryResult(rptinfo) {
          return Promise((s, f) => {
              this.TabValue = this.Options.generesultcaninput == "1" ? "1" : "2";
              let reportid = rptinfo.reportid;
              this.Refreshflag = true;
              if (rptinfo.rechkflag == "9" || (this.Options.onlymodifymyreport == "1" && $tool.getSession(this.$tool.loginuserno) != rptinfo["report_user"]) || (rptinfo.barcode && rptinfo.barcode.indexOf("-退") > -1)) {
                  this.editflag = false;
              } else {
                  this.editflag = true;
              }
              let logcontent = "";
              logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :开始查询报告: " + reportid + "\r\n";
              if(this.Options.showreportview == "1"){
                  this.TabValue = "5";
                  if (reportid) {
                      this.queryreportview(reportid);
                  } else {
                      this.queryreportview("no");
                  }
              }
              //this.$pub.Log("开始查询报告:" + reportid);
              this.$tool
                  .request({
                      url: "LIS/LIS3/LIS310",
                      method: "post",
                      data: {
                          action: "queryresultlist",
                          reportid: reportid,
                          rptunitid: rptinfo.rptunitid,
                          sampleno: rptinfo.sampleno,
                          sampledate: rptinfo.sampledate,
                          checkmode: this.Checkmode ? "1" : "0"
                      }
                  })
                  .then(res => {
                      logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :result开始查询报告结束: " + reportid + "\r\n";
                      //this.$pub.Log("result开始查询报告结束:" + reportid);
                      console.log("resultdata", res.vxtab.Data);
                      if (this.Checkmode && res.vxtab.Data.length > 0 && res.rptinfo && res.rptinfo.hasOwnProperty("reportid") && res.rptinfo.reportid && res.rptinfo.hasOwnProperty("pat_no") && res.rptinfo.pat_no) this.tableDataResult = this.AppendHistoryData(res.vxtab.Data, res.redt);
                      else this.tableDataResult = res.vxtab.Data;
                      this.noupdateflag = true;
                      this.tableDataResultOld = [];
                      //this.$refs.xTableResult.clearActived();
                      //rptinfo.redo_flag = res.redo_flag;
                      //rptinfo.alter_flag = res.alter_flag;
                      this.loadingResult = false;
                      this.Refreshflag = false;
                      var lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult");
                      if (lasttitle) {
                          //如果有值就显示，没有就用默认历史结果
                          if(res.historytitle) lasttitle.title = res.historytitle;
                          else lasttitle.title = "历史结果";
                      }
                      //this.tableResultColumn.filter(item => item.field == "cp_lastresult")[0].title = res.historytitle;
                      //end
                      if (res.rptinfo != null) res.rptinfo.specialtype = res.specialtype;
                      //查询基因位点图数据
                      if (res.rptinfo != null) {
                          this.txtinfo1 = res.rptinfo.txtinfo1;
                          this.txtinfo2 = res.rptinfo.txtinfo2;
                          this.lab_advice = res.rptinfo.lab_advice;
                          if(this.Options.generesultcaninput != '1'){
                              this.$refs.resultgene.QueryGene(res.rptinfo);
                          }
                          this.Generesult = res.rptinfo.txtinfo1 + "\n" + (res.rptinfo.reserve1 ? ("高危型HPV:" + res.rptinfo.reserve1) : "") + "\n" + (res.rptinfo.reserve2 ? ("低危型HPV:" + res.rptinfo.reserve2) : "");
                      } else {
                          this.txtinfo1 = "";
                          this.txtinfo2 = "";
                          this.lab_advice = "";
                          if(this.Options.generesultcaninput != '1'){
                              this.$refs.resultgene.QueryGene({ barcode: "", reportid: "" });
                          }
                          this.Generesult = "";
                      }

                      var returndata = { res: res.rptinfo, redo: res.redo, history: res.history, sampleno: res.sampleno };
                      //不在前台做待审核状态判断了
                      //var renum = 1;
                      //if (res.vxtab.Data && res.vxtab.Data.length > 0) renum = this.tableDataResult.filter(item => !item.result_str || item.result_str == "" || item.result_str == "未做").length;
                      this.$emit("PatChange", res.rptinfo, res.prechkflag, "");
                      logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :result开始查询报告赋值结束: " + reportid + "\r\n";
                      this.$pub.Log(logcontent);
                      s(returndata);
                  })
                  .catch(error => {
                      this.$message.error("错误:" + error);
                      this.Refreshflag = false;
                      f();
                  });
          });
      },

      //后台调用计算参考值
      CalcRef(row) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "calcref",
                      sex: this.PatientInfo.pat_sex,
                      ageyear: this.PatientInfo.pat_birth ? this.PatientInfo.pat_birth : this.PatientInfo.pat_agestr,
                      specimen: this.PatientInfo.specimen_code,
                      physicycle: this.PatientInfo.physicycle,
                      deptno: this.PatientInfo.req_deptno,
                      diagicd: this.PatientInfo.pat_diag_icd,
                      sampledate: this.PatientInfo.sampledate,
                      rptunitid: this.PatientInfo.rptunitid,
                      sampleno: this.PatientInfo.sampleno,
                      hospcode: this.PatientInfo.hospcode,
                      resultrow: row
                  }
              })
              .then(res => {
                  for (var item in res) {
                      row[item] = res[item];
                  }
              })
              .catch(error => {
                  this.$message.error("错误:" + error);
              });
      },
      QueryResultAll(rptitemcode, rekind) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "getrptitemval",
                      rpt_itemcode: rptitemcode,
                      resultkind: rekind,
                      rptunitid: this.myrptunitid
                  }
              })
              .then(res => {
                  this.tableColumnResultAll = res.Cols;
                  this.tableDataResultAll = res.Data;
                  this.tableDataResultS = res.Data;
                  if (this.tableDataResultAll.length > 0 && this.Options.showrptitemvalbyfocus == "2") {
                      this.textvalueshow = true;
                  }
              });
      },
      QueryItemHistory(rptitemcode) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "queryitemhistoryresult",
                      rptitemcode: rptitemcode,
                      reportid: this.PatientInfo.reportid,
                      rptunitid: this.myrptunitid
                  }
              })
              .then(res => {
                  if (res) {
                      this.tableItemHData = res;
                      this.dialogItemhistoryVisible = true;
                  }
              });
      },
      QueryLinkItem(rptitemcode) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "querylinkitem",
                      rptitemcode: rptitemcode,
                      reportid: this.PatientInfo.reportid,
                      rptunitid: this.myrptunitid
                  }
              })
              .then(res => {
                  if (res.errcode == "1") {
                      this.tableDataLink = [];
                      for (let i = 0; i < res.dtlink.length; i++) {
                          let datas = res.dt.filter(item => item.rpt_itemcode == res.dtlink[i].link_rptitemcode);
                          if (datas.length > 1) res.dtlink[i].children = datas.slice(1);
                          this.tableDataLink.push(res.dtlink[i]);
                          if (datas.length > 0) {
                              res.dtlink[i].result_str = datas[0].result_str;
                              res.dtlink[i].result_ref = datas[0].result_ref;
                              res.dtlink[i].result_flag = datas[0].result_flag;
                              res.dtlink[i].sampledate = datas[0].sampledate;
                              res.dtlink[i].sampleno = datas[0].sampleno;
                              res.dtlink[i].rptunitname = datas[0].rptunitname;
                              res.dtlink[i].rpt_itemcode = datas[0].rpt_itemcode;
                          }
                      }
                      console.log("link", this.tableDataLink);
                      //this.tableDataLink = res.dt;
                  }
              });
      },
      //病历号改变的逻辑

      //Result弹出框的各项方法
      ResultSearchInput(value) {},
      ResultSearchkeydown() {
          this.tableDataResultS = this.tableDataResultAll.filter(item => item.textvalue.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || (item.seq + "").indexOf(this.Resultqcode.toUpperCase()) > -1);
      },
      Resultok() {
          var row = this.$refs.xTableResultAll.getCurrentRow();
          if (row) {
              var uprow = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == row.rpt_itemcode)[0];
              if (this.dialogResultItem == "result_str") {
                  uprow.result_flag = row.result_flag;
                  uprow.redoflag = row.redoflag;
                  uprow.limitflag = row.limitflag;
              }
              uprow[this.dialogResultItem] = row.textvalue;
              this.CalcRef(uprow);
              this.dialogResultVisible = false;
              this.dialogResultItem = "";
          } else {
              this.$message("未选中报告结果!");
          }
      },
      Resultcancel() {
          this.dialogResultVisible = false;
          this.dialogResultItem = "";
      },
      ResultSelect({ row }) {
          var uprow = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == row.rpt_itemcode)[0];
          if (this.dialogResultItem == "result_str") {
              uprow.result_flag = row.result_flag;
              uprow.redoflag = row.redoflag;
              uprow.limitflag = row.limitflag;
          }
          uprow[this.dialogResultItem] = row.textvalue;
          this.CalcRef(uprow);
          this.dialogResultVisible = false;
          this.dialogResultItem = "";
      },
      LinkClick({ row, column }) {
          this.LinkChartShow = false;
          this.DrawCharts("dialogLinkChart", row);
      },

      DrawCharts(chartname, row) {
          var xline = [];
          var xlinefield = [];
          var data = [];
          var column = [];
          if (row) {
              var datarow = this.tableDataLink.find(item => item.rpt_itemcode == row.rpt_itemcode);
              if (datarow && parseFloat(datarow.result_str) != NaN) {
                  xline.push(datarow.sampledate.trim());
                  xlinefield.push(datarow.sampledate.trim() + " " + datarow.sampleno.trim());
                  data.push(parseFloat(datarow.result_str));
              } else {
                  return;
              }
              if (datarow.hasOwnProperty("children") && datarow.children.length > 0) {
                  for (let i = 0; i < datarow.children.length; i++) {
                      if (parseFloat(datarow.children[i].result_str) != NaN) {
                          xline.push(datarow.children[i].sampledate.trim());
                          xlinefield.push(datarow.sampledate.trim() + " " + datarow.sampleno.trim());
                          data.push(parseFloat(datarow.children[i].result_str));
                      }
                  }
              }
              if (data.length > 0) {
                  this.LinkChartShow = true;
              } else {
                  this.LinkChartShow = false;
              }
              // for (let i = 0; i < column.length; i++) {
              //     if (column[i].title != "项目") {
              //         if (row[column[i].field]) {
              //             xline.push(column[i].title);
              //             xlinefield.push(column[i].field);
              //         }
              //     }
              // }
              // for (let j = 0; j < xlinefield.length; j++) {
              //     if (row[xlinefield[j]]) {
              //         data.push(row[xlinefield[j]]);
              //     }
              // }
          }
          console.log("data", data);
          console.log("xline", xline);
          //console.log("x",xline,data);
          //echarts画图
          this.$nextTick(() => {
              this.charts = echarts.init(document.getElementById(chartname));
              this.charts.setOption({
                  title: {
                      text: datarow.rpt_itemname,
                      textAlign: "center",
                      x: "center",
                      y: "top"
                  },
                  tooltip: {
                      trigger: "axis"
                  },
                  grid: {
                      left: "3%",
                      right: "4%",
                      bottom: "3%",
                      containLabel: true
                  },
                  xAxis: {
                      name: "",
                      nameLocation: "middle",
                      type: "category",
                      boundaryGap: true,
                      data: xline,
                      axisLabel: {
                          fontSize: 8
                      }
                  },
                  yAxis: {
                      name: "",
                      nameLocation: "middle",
                      boundaryGap: false,
                      type: "value",
                      axisLabel: {
                          fontSize: 8
                      }
                  },
                  series: [
                      {
                          name: "结果",
                          type: "line",
                          stack: "总量",
                          data: data
                      }
                  ]
              });
          });
      },
      AdviceClick({ row }) {
          console.log("row", row);
          if (this.ResultTxt) {
              if (this.appendChangeRow) {
                  this.ResultTxt += "\n" + row.textvalue;
              } else {
                  if (this.ResultTxt) {
                      this.ResultTxt += "," + row.textvalue;
                  } else {
                      this.ResultTxt += row.textvalue;
                  }
              }
          } else {
              this.ResultTxt = row.textvalue;
          }
      },
      AdvicedblClick({ row }) {
          this.ResultTxt = row.textvalue;
      },
      AdviceSubmit() {
          this.tempRptItem.result_txt = this.ResultTxt;
          this.dialogResultTxtVisible = false;
      },
      SpaceEvent(type) {
          var val = this.PatientInfo[type + "name"];
          if (!val.replace(/\s*/g, "")) {
              this.inputdblEvent(type);
          }
      },

      //危急值上报弹窗
      CheckDangerDeal(type) {
          var alertinfo = {
              chksendhis: this.sendbyhis ? "1" : "0",
              chkphone: this.noticebyphone ? "1" : "0",
              chkmessage: this.noticebymsg ? "1" : "0",
              chkrepeat: this.retelled ? "1" : "0",
              chkmsguser: this.msgtodutyman ? "1" : "0",
              chkmsggrdept: this.noticeinfec ? "1" : "0",
              alertuser: this.ExaminreportMan,
              rectelman: this.noticeddoctor,
              shortmsgtelnum: this.noticeddoctorno,
              memo: this.remarks
          };
          this.CheckReportRequest(this.InputMsg, type, alertinfo);
      },
      selectchange(item, row) {
          // console.log("111",val);
          row.result_str = item.textvalue;
          row.result_flag = item.result_flag;
          this.$refs.xTableResult.clearActived();
      },
      querySearch(str, cb) {
          var results = this.tableDataResultAll;
          // 调用 callback 返回建议列表的数据
          //报告单元选项不显示文字结果
          if (this.Options.showrptitemvalbyfocus != "1") {
              results = [];
          }
          cb(results);
      },
      CancelDel() {
          var removerecord = this.$refs.xTableResult.getRemoveRecords();
          var removeinsertdata = [];
          for (let i = 0; i < removerecord.length; i++) {
              if (!this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == removerecord[i].rpt_itemcode)) {
                  removeinsertdata.push(removerecord[i]);
              }
          }
          this.tableDelData = removeinsertdata;
          this.dialogDelVisible = true;
      },
      SubmitCancelDel() {
          var removerecord = this.$refs.xTableDel.getSelectRecords();
          if (removerecord && removerecord.length > 0) {
              for (let i = 0; i < removerecord.length; i++) {
                  if (!this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == removerecord[i].rpt_itemcode)) {
                      this.$refs.xTableResult.insertAt(removerecord[i], -1);
                  }
              }
          }
          this.dialogDelVisible = false;
      },
      handleIconClick() {
          this.textvalueshow = !this.textvalueshow;
          // if (this.iconclass == "el-icon-arrow-down") {
          //     this.iconclass = "el-icon-arrow-up";
          //     this.textvalueshow = true;
          // } else {
          //     this.iconclass = "el-icon-arrow-down";
          //     this.textvalueshow = false;
          // }
      },
      ResultDblClick() {
          //this.QueryResultAll(row.rpt_itemcode, 0);
          this.textvalueshow = false;
          this.dialogResultVisible = true;
          this.dialogResultItem = "result_str";
          if (this.tableDataResultS.length > 0) {
              this.$nextTick(() => {
                  this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
              });
          }
      },
      ResultTextClick({ row }, rptrow) {
          rptrow.result_str = row.textvalue;
          rptrow.result_flag = row.result_flag;
          this.textvalueshow = false;
      },
      colspanMethod({ row, rowIndex, column, columnIndex, data }) {
          if (row.isgroup === 1) {
              if (columnIndex === 0) {
                  return { rowspan: 1, colspan: 6 };
              } else if (columnIndex === 2 || columnIndex === 3 || columnIndex === 4 || columnIndex === 5 || columnIndex === 1) {
                  return { rowspan: 0, colspan: 0 };
              }
          }
      },
      rowClassName({ row, rowIndex }) {
          if (row.isgroup === 1) {
              return "parent-row";
          }
      },
      //添加历史结果
      AppendHistoryData(redt, redtall) {
          var dt = redt;

          for (let i = 0; i < dt.length; i++) {
              dt[i].cp_lastresult1 = redtall[i].cp_lastresult1;
              dt[i].cp_lastresultflag1 = redtall[i].cp_lastresultflag1;
              dt[i].cp_lastresult2 = redtall[i].cp_lastresult2;
              dt[i].cp_lastresultflag2 = redtall[i].cp_lastresultflag2;
              dt[i].cp_lastresult3 = redtall[i].cp_lastresult3;
              dt[i].cp_lastresultflag3 = redtall[i].cp_lastresultflag3;
              dt[i].cp_lastresult4 = redtall[i].cp_lastresult4;
              dt[i].cp_lastresultflag4 = redtall[i].cp_lastresultflag4;
          }
          if (this.Options.refresultmixreport != "1") {
              var one = redtall.find(item => item.cp_lastresultdays != "");
              var tow = redtall.find(item => item.cp_lastresultdays1 != "");
              var three = redtall.find(item => item.cp_lastresultdays2 != "");
              var four = redtall.find(item => item.cp_lastresultdays3 != "");
              var five = redtall.find(item => item.cp_lastresultdays4 != "");
              var lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult");
              if (one && lasttitle) lasttitle.title = one.cp_lastresultdays;
              else lasttitle.title = "历史结果";
              lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult1");
              if (tow && lasttitle) lasttitle.title = tow.cp_lastresultdays1;
              else lasttitle.title = "历史结果1";
              lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult2");
              if (three && lasttitle) lasttitle.title = three.cp_lastresultdays2;
              else lasttitle.title = "历史结果2";
              lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult3");
              if (four && lasttitle) lasttitle.title = four.cp_lastresultdays3;
              else lasttitle.title = "历史结果3";
              lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult4");
              if (five && lasttitle) lasttitle.title = five.cp_lastresultdays4;
              else lasttitle.title = "历史结果4";
          }

          return dt;
      },
      //结果改变判断事件
      StrChange(row) {
          if (this.Options.modifyresultmsg == "2") {
              if (this.noupdateflag) {
                  var result = this.$refs.xTableResult.getUpdateRecords();
                  if (result.length == 0) return;
                  var index = result.find(item => item.odata.rpt_itemcode == row.rpt_itemcode);
                  if (index) {
                      this.$confirm("是否修改当前项目结果", "提示", {
                          confirmButtonText: "确定",
                          cancelButtonText: "取消",
                          focusCancelButton: false,
                          type: "warning"
                      })
                          .then(() => {
                              this.noupdateflag = false;
                              this.CalcRef(row);
                          })
                          .catch(() => {
                              this.noupdateflag = false;
                              row.result_str = index.odata.result_str;
                          });
                  }
              }
          } else if (this.Options.modifyresultmsg == "3") {
              var result = this.$refs.xTableResult.getUpdateRecords();
              if (result.length == 0) return;
              var index = result.find(item => item.odata.rpt_itemcode == row.rpt_itemcode);
              if (index) {
                  var olditem = this.tableDataResultOld.find(item => item.rpt_itemcode == row.rpt_itemcode);
                  this.$confirm("是否修改当前项目结果", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      focusCancelButton: false,
                      type: "warning"
                  })
                      .then(() => {
                          this.CalcRef(row);
                          if (olditem) olditem.value = row.result_str;
                          else this.tableDataResultOld.push({ rpt_itemcode: row.rpt_itemcode, value: row.result_str });
                      })
                      .catch(() => {
                          if (olditem) row.result_str = olditem.value;
                          else row.result_str = index.odata.result_str;
                      });
              }
          } else {
              this.CalcRef(row);
          }
      },
      ResultTabClick(tab) {
          if (tab.name == 5) {
              this.queryreportview();
          }
      },
      queryreportview(reportid) {
          this.reportviewstr = "";
          if (!reportid) {
              reportid = this.PatientInfo.reportid;
          }
          if (reportid && reportid != "no") {
              this.$tool
                  .request({
                      url: "ucent/print",
                      method: "post",
                      data: {
                          action: "reportprintview",
                          reportid: reportid,
                          env: "1"
                      }
                  })
                  .then(res => {
                      if (res.flag == "0") {
                          this.reportviewstr = res.msg;
                      } else {
                          this.reportviewstr = '<embed id="embed-report" width="100%" height="' + (document.getElementById("reportviewid").clientHeight - 32) + 'px"  name="plugin" src="' + res.pdfurl + '#toolbar=0" type="application/pdf" >';
                      }
                  })
                  .catch(e => {
                      this.$alert("预览报告出错！", "错误", {
                          confirmButtonText: "确定"
                      });
                  });
          }
      },
      getlabname(){
          // 获取名字
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS314",
                  method: "post",
                  data: {
                      action: "querycolname",
                      rptunitid: this.myrptunitid,
                  }
              })
              .then((res)=>{
                  if(res.txtinfo1name != ""){
                      this.txtinfo1name = res.txtinfo1name;
                  }
                  if(res.txtinfo2name != ""){
                      this.txtinfo2name = res.txtinfo2name;
                  }
              })
          var name = this.txtinfo1name+ "/" + this.txtinfo2name;
          return name;
      },
      GeneChange(data) {
          if (data) {
              let row = this.$refs.xTableResult.afterFullData.find(item => item.rpt_itemcode == data.rpt_itemcode);
              if (row) {
                  row.result_str = data.result_str;
                  this.CalcRef(row);
              }
          }
      },
      txtinfoChange(val) {
          this.$emit("change", val);
      }
  },
  watch: {
      rptunitid(val) {
          this.myrptunitid = val;
      },
      textvalueshow(val) {
          if (val) {
              this.iconclass = "el-icon-arrow-up";
          } else {
              this.iconclass = "el-icon-arrow-down";
          }
      },
      dialogLinkRptVisible(val) {
          if (!val) {
              let currentrow = this.$refs.xTableResult.getCurrentRow();
              this.linkshow = true;
              this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname");
          }
      }
  }
};
</script>

<style scoped>
::v-deep .disabled-cell {
  background-color: #f7f7f7;
}
::v-deep .warn-high {
  background-color: #ffc0c0;
}
::v-deep .warn-low {
  background-color: #c0c0ff;
}
::v-deep .danger {
  background-color: #ff0000;
}
::v-deep .unprint {
  color: #ea66a6;
}
::v-deep .paddingcolumn {
  padding: 0 3px;
}
::v-deep .fontbold {
  font-weight: bold;
}
::v-deep .el-image {
  z-index: 2007;
}
::v-deep .vxe-body--row .el-input--small .el-input__inner {
  height: 18px !important;
  line-height: 18px !important;
}
::v-deep .middle-left .el-checkbox__input.is-checked + .el-checkbox__label {
  color: red;
}
::v-deep .dialogdanger .el-textarea.is-disabled .el-textarea__inner {
  color: red;
}
::v-deep .el-input--small .el-input__icon {
  line-height: 18px !important;
}
.menu_style {
  position: absolute;
  width: 150px;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 2px 2px 14px #d0d0d0;
  z-index: 2008;
}
.menu_style > ul > li {
  text-indent: 25px;
  height: 38px;
  line-height: 38px;
  border-bottom: 1px dashed #f0f0f0;
  cursor: pointer;
}
.menu_style > ul > li:hover {
  background: #e0eeff;
}
.dangerPatInfo tr td:nth-child(even) {
  width: 40px;
  border-bottom: 1px solid black;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}
table tr td:nth-child(even) {
  text-align: left;
}
table tr td:nth-child(1) {
  width: 80px;
}
.reqitem-dialog {
  position: absolute;
  z-index: 10000;
}
::v-deep .ResultTable.vxe-table .vxe-cell {
  padding: 0;
  line-height: 18px;
}
::v-deep .paddingcolumn .vxe-cell {
  padding: 0 3px;
}
.el_main {
  padding: 0 0;
}
::v-deep .ResultTable .vxe-table--body td {
  height: 18px !important;
}
::v-deep .txtClass .el-textarea__inner {
  padding: 0;
}
::v-deep .ResultTxtTable.vxe-table .vxe-body--row td {
  background-color: #fff !important;
}
::v-deep .ResultTxtTable.vxe-table .vxe-body--row.row--hover td {
  background-color: #d7f1fd !important;
}
::v-deep  .parent-row .vxe-cell {
  width: 100% !important;
}
::v-deep .el-textarea.is-disabled .el-textarea__inner {
  color: #606266;
}
</style>
